<?php
/**
 * Created by Allen.
 * User: Allen
 * Date: 15-07-21
 * Time: 09:26
 */

class Comment_model extends HS_Model {

    //评论
    public function getCommentlist($where = array(),$order_by = 'id asc')
    {
    	return $this->select('comment.id,comment.content,comment.create_time,user.username')
    	->join('user','user.id=comment.user_id')
    	->where($where)->order_by($order_by)->find_all();
    }
    
    //计算行数
    public function getCount($where = array())
    {
    	return $this->where($where)->count();
    }  
    //添加
    public function addComment($data)
    {
    	if ($this->add($data))
    	{
    		return $this->db->insert_id();
    	}
    }
    
    //删除
    public function deleteComment($where)
    {
    	return $this->where($where)->delete();
    }
    
 }
